package com.lvs.zmwz.controller.admin;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lvs.zmwz.entity.SysManager;
import com.lvs.zmwz.entity.req.SysManagerReq;
import com.lvs.zmwz.entity.serach.SysManagerSearch;
import com.lvs.zmwz.service.ISysManagerService;
import com.lvs.zmwz.util.QPage;
import com.lvs.zmwz.util.ResultView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 * 后台账户表 前端控制器
 * </p>
 *
 * @author lbk
 * @since 2021-10-19
 */
@RestController
@RequestMapping("/api/admin/manager")
public class SysManagerController {

    @Autowired
    private ISysManagerService iSysManagerService;

    /**
     * 用户列表
     * @return
     */
    @GetMapping("/list")
    public ResultView list(QPage qPage, SysManagerSearch sysManagerSearch) {
        IPage<SysManager> hjRoleList=this.iSysManagerService.getListAll(qPage,sysManagerSearch);
        return ResultView.ok(hjRoleList);
    }

    /**
     * 获取所以的负责人
     * @return
     */
    @GetMapping("/sysManagerList")
    public ResultView sysManagerList() {
        List<SysManager> sysManagerList=this.iSysManagerService.manageList();
        return ResultView.ok(sysManagerList);
    }


    @GetMapping("/getManagerId")
    public ResultView getManagerId(@NotNull(message = "账户ID不能为空") String managerId) {
        return this.iSysManagerService.getManagerId(managerId);
    }


    /**
     * 修改用户
     * @param hjManagerReq
     * @return
     */
    @PostMapping("/updateManager")
    public ResultView updateRole(@Validated SysManagerReq hjManagerReq) {
        return this.iSysManagerService.updateManager(hjManagerReq);
    }


    @PostMapping("/restPwd")
    public ResultView restPwd(@NotNull(message = "账户ID不能为空") String managerId,
                              @NotNull(message = "密码不能为空") String mPwd) {
        return this.iSysManagerService.restPwd(managerId,mPwd);
    }



}
